package com.example.threadcoroutine

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

class MyViewModel: ViewModel() {

    suspend fun test() = withContext(Dispatchers.IO){
        viewModelScope.launch {

        }
    }

    fun loadData(): Flow<Int> {
        var mflow:Flow<Int> = flowOf()
        viewModelScope.launch(Dispatchers.IO) {
                mflow = flow{
                    emit(10)
                }
        }
        return mflow
    }
}